package com.ele.ui;

import java.util.Scanner;

import com.ele.pojo.Shop;
import com.ele.service.ShopService;

/**
 * 	商家功能界面
 * @author candy
 *
 */
public class ShopManager {
	private static Scanner sc = new Scanner(System.in);
	/**
	 * 	修改店铺信息界面
	 * @param shop	登入后的店铺信息
	 */
	public void updateShop(Shop shop) {
		System.out.println("请选择想要更新的数据：");
		System.out.println("1.商铺名	2.地址	3.描述	4.起步价	 5.配送费	  6.商铺状态	7.商铺密码");
		String input = sc.next();
		if (input.equals("1")) {
			System.out.println("请输入更改之后的名字：");
			shop.setShopName(sc.next());
		}else if (input.equals("2")) {
			System.out.println("请输入更改之后的地址：");
			shop.setAddr(sc.next());
		}else if (input.equals("3")) {
			System.out.println("请输入更改之后的描述：");
			shop.setShopDesc(sc.next());
		}else if (input.equals("4")) {
			System.out.println("请输入更改之后的起步价：");
			shop.setStartPrice(Double.parseDouble(sc.next()));
		}else if (input.equals("5")) {
			System.out.println("请输入更改之后的配送费：");
			shop.setFee(Double.parseDouble(sc.next()));
		}else if (input.equals("6")) {
			System.out.println("请输入更改之后的状态：1.休息 2.营业中");
			Integer x = Integer.parseInt(sc.next());
			if (x == 1) {
				shop.setShopStatus(0);
			}else if(x == 2) {
				shop.setShopStatus(1);
			}else {
				System.out.println("输入错误");
			}
			
		}else if (input.equals("7")) {
			System.out.println("请输入更改之后的密码：");
			shop.setPassword(sc.next());
		}else {
			System.out.println("输入不正确！");
		}
		System.out.println("是否继续修改？y/n");
		if (sc.next().equalsIgnoreCase("y")) {
			updateShop(shop);
		}else {
			ShopService ss = new ShopService();
			int x = ss.updateShop(shop);
			if (x == 1) {
				System.out.println("修改成功");
			}
		}
	}
	/**
	 * 	菜品维护功能界面
	 * @param shop
	 */
	public void foodManager(Shop shop) {
		System.out.println("1.添加菜品\t2.修改菜品\t3.搜索菜品\t4.退出");
		String input = sc.next();
		FoodManager foodManager = new FoodManager(); 
		if (input.equals("1")) {
			foodManager.addFood(shop);
		}else if (input.equals("2")) {
			foodManager.updateFood(shop);
		}else if (input.equals("3")) {
			foodManager.selectFood(shop);
		}else if (input.equals("4")) {
			System.out.println("是否退出？y/n");
			if (sc.nextLine().equalsIgnoreCase("y")) {
				return;
			}
		}else {
			System.out.println("输入不正确");
		}
		foodManager(shop);
	}
	/**
	 * 	查询店铺信息界面
	 * @param shop
	 */
	public void shopInform(Shop shop) {
		System.out.println(shop);
		
	}

}
